package vg.services.graph_view_manager.realization.graph_view.smart_graph_view.interfaces;

import java.awt.Color;
import java.util.Collection;
import java.util.Map;
import java.util.Observer;
import java.util.Set;

import javax.swing.JComponent;
import javax.swing.JMenuItem;

import org.apache.commons.lang.mutable.MutableBoolean;

import vg.services.data_base_manager.data.graph.Attribute;
import vg.services.data_base_manager.data.graph.Edge;
import vg.services.data_base_manager.data.graph.Graph;
import vg.services.data_base_manager.data.graph.Vertex;
import vg.services.graph_view_manager.interfaces.graph_view.graph_lib_depending.AMainGraphComponent;

/**
 * @author Timur Zolotuhin (e-mail: tzolotuhin@gmail.com)
 */
public interface ISGVGraphView4Patching {
//=============================================================================
//-----------------Methods for getting different views-------------------------
	/**
	 * Returns graph representation.
	 */
	public JComponent getView();
	
	/**
	 * Returns minimap of graph representation.
	 */
	public JComponent getMiniMap();
	
	/**
	 * Refresh.
	 */
	public void refreshView();	
//=============================================================================
//-----------------Methods for editing graph-----------------------------------
	/**
	 * Sets types of graph: directed or undirected.
	 */
	public void setDirected(boolean directed);
	
	/**
	 * This method adds new vertex to graph.
	 */
	public void addVertex(Vertex vertex);
	
	/**
	 * This method adds new vertices to graph.
	 */
	public void addVertices(Collection<Vertex> vertices);

	/**
	 * This method adds new edge to graph.
	 */
	public void addEdge(Edge edge);
	
	/**
	 * This method adds new edges to graph.
	 */
	public void addEdges(Collection<Edge> edges);
	
	/**
	 * This methods adds new attribute to graph view for vertex.
	 */
	public void addAttribute4Vertex(Attribute attr, Vertex vertex);
	
	/**
	 * This methods adds new attribute to graph view for edge.
	 */
	public void addAttribute4Edge(Attribute attr, Edge edge);

	/**
	 * This methods sets graph model id.
	 */
	public void setGraphModelId(int graphGraphId);
	
	/**
	 * This gets sets graph model id.
	 */
	public int getGraphModelId();
	
	/**
	 * This methods sets graph id.
	 */
	public void setGraphId(int graphId);
	
	/**
	 * This methods gets graph id.
	 */
	public int getGraphId();
	
//=============================================================================
//-----------------Methods for getting information about graph elements--------
	/**
	 * This method returns information about all vertices.
	 */
	public Map<Vertex, Map<Attribute, MutableBoolean>> getAllVerticesInfo();

	/**
	 * This method returns information about all edges.
	 */
	public Map<Edge, Map<Attribute, MutableBoolean>> getAllEdgesInfo();
	
	/**
	 * This method returns information about selection vertices.
	 */
	public Map<Vertex, Map<Attribute, MutableBoolean>> getSelectionVerticesInfo();

	/**
	 * This method returns information about selection edges.
	 */
	public Map<Edge, Map<Attribute, MutableBoolean>> getSelectionEdgesInfo();
	
	/**
	 * This method returns all graph.
	 */
	public Graph getGraph();

	/**
	 * This methods returns selection subgraph.
	 */
	public Graph getSelectionSubGraph();

//=============================================================================
//-----------------Methods for changing visualization from elements------------
	/**
	 * This method makes marked vertices by invisible.
	 * 
	 * @param vertexIds
	 *          - marked vertices.
	 */
	public void setInvisibleVertices(Set<Integer> vertexIds);

	/**
	 * This method makes marked edges by invisible.
	 * 
	 * @param vertexIds
	 *          - marked edges.
	 */
	public void setInvisibleEdges(Set<Integer> edgeIds);

	/**
	 * This method makes marked all vertices by invisible, but vertices which
	 * place <b>vertexIds</b> array.
	 * 
	 * @param vertexIds
	 *          - marked vertices.
	 */
	public void setInvisibleAllVerticesBut(Set<Integer> vertexIds);

	/**
	 * This method makes marked edges by invisible, but edges which place
	 * <b>edgeIds</b> array.
	 * 
	 * @param edgeIds
	 *          - marked edges.
	 */
	public void setInvisibleAllEdgesBut(Set<Integer> edgeIds);
	
	/**
	 * This method shows attributes in vertexes and edges.
	 */
	public void showAttributes(final Set<String> vertexAttr, final Set<String> edgeAttr);
	
	/**
	 * This method provide ability to select part of graph.
	 * 
	 * @param lvsids
	 *          list of vertex storableIds
	 * @param lesids
	 *          list of edge storableIds
	 */
	public void setSelectionElements(Set<Integer> lvsids, Set<Integer> lesids);
	
	/**
	 * Paints vertex v to color c.
	 */
	public void setColor4Vertex(Color c, Vertex v);
	
	/**
	 * Paints edge e to color c.
	 */
	public void setColor4Edge(Color c, Edge e);
	
	/**
	 *  vertex v to color c.
	 */
	public void setShape4Vertex(String shape, Vertex v);
	
	/**
	 * Paints edge e to color c.
	 */
	public void setShape4Edge(String shape, Edge e);
	
	/**
	 * This method sets style for elements of graph.
	 *  
	 * @param style - see constants DEF_STYLE_VERTEX_SPACING_LEFT, DEF_STYLE_VERTEX_SHAPE, i.e.
	 */
	public void setStyle(String style, Object value);
	
	public void setStyle(Map<String, Object> stylesheet);
	
//=============================================================================
//-----------------Methods for adding observers to graph representation--------
	/**
	 * Adds an observer to the set of observers for this object.
	 */
	public boolean addObserver(Observer o);

	/**
	 * Removes an observer from the set of observers of this object.
	 */
	public boolean removeObserver(Observer o);

	/**
	 * Removes all observers from the set of observers of this object.
	 */
	public void removeAllObservers();
	
	/**
	 * Adds popup menu item.
	 */
	public void addPopupMenuItem(JMenuItem item);
	
	/**
	 * Removes popup menu item.
	 */
	public void removePopupMenuItem(JMenuItem item);

//=============================================================================
//-----------------Undo/Redo methods-------------------------------------------
	/**
	 * Undo method.
	 */
	public void undo();
	
	/**
	 * Redo method.
	 */
	public void redo();

//=============================================================================
//-----------------Panning-----------------------------------------------------
	public void setPanning(boolean panning);

	public boolean isPanning();	
			
//=============================================================================
//-----------------Methods for scaling graph-----------------------------------
	/**
	 * This method increase scale of graph
	 */
	public void zoomIn();

	/**
	 * This method decrease scale of graph
	 */
	public void zoomOut();

//=============================================================================
//-----------------Methods for algorithms--------------------------------------
	/**
	 * Shows critical path
	 */
	public void showCriticalPath(Vertex source, Vertex target, boolean maximum, String attrName);
	
	/**
	 * Shows all cycles, which contains vertex v.
	 */
	public void showCycles(Vertex v);
	
	/**
	 * Shows all paths from vertex source to vertex target.
	 */
	public void showPaths(Vertex source, Vertex target);
	
//=============================================================================
//-----------------Access methods to low level components----------------------
	/**
	 * This methods returns main components (it's may be 
	 * JGraph components, yEd components or other),
	 * which places in low level of realization.
	 */
	public AMainGraphComponent getMainGraphComponents();

}
